import BankItem from "./BankItem";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Button)
    private closeBtn:cc.Button = null;

    //@property(Array)
    //private items:Array<any> = [];

    private itemArr:Array<any> = [19,20,21,19,20,21,19,20,21,19,20,21,19,20];

    @property(cc.Prefab)
    private itemPrefab:cc.Prefab = null;

    @property(cc.Node)
    private itemListGroup:cc.Node = null;

    @property(cc.ScrollView)
    private scrollView:cc.ScrollView = null;

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {
        this.closeBtn.node.on(cc.Node.EventType.TOUCH_END,this.clean,this);

        for (var i = 0; i < this.itemArr.length; ++i) 
        {
            var item = cc.instantiate(this.itemPrefab);
            var data = this.itemArr[i];
            this.scrollView.content.addChild(item);

            item.getComponent('BankItem').init({
                id: data
            });
        }

    }

    // update (dt) {}

    lateUpdate(){

    }

    private clean():void
    {   
        this.closeBtn.node.off(cc.Node.EventType.TOUCH_END,this.clean,this); 
        this.node.destroy();
    }

    onDestroy(){
       
    }

    onEnable(){

    }

    onDisable(){

    }
}
